package com.example.provider;

import java.util.List;

import com.example.model.LEARNTEXT;
import com.example.pinyin.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class LearnTextAdapter extends BaseAdapter {
	
	public List<LEARNTEXT> list;
	public LayoutInflater mLayoutInflater;
	public Context mContext;
	public ViewHolder mViewHolder;
	public String TName,TArm,TText;
	
	public LearnTextAdapter(Context context ,List<LEARNTEXT> list){
		this.mContext=context;
		this.list=list;
		this.mLayoutInflater= LayoutInflater.from(context);
	}
	
	class ViewHolder{
		TextView TextName,TextArm,TextText;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView = mLayoutInflater.inflate(R.layout.learntext_adapter_item, null);
			mViewHolder = new ViewHolder();
			mViewHolder.TextName= (TextView) convertView.findViewById(R.id.tv_text_name);
			mViewHolder.TextArm= (TextView) convertView.findViewById(R.id.tv_text_arm);
			mViewHolder.TextText= (TextView) convertView.findViewById(R.id.tv_text_text);
			convertView.setTag(mViewHolder);
		}else{
			mViewHolder = (ViewHolder) convertView.getTag();
		}
		mViewHolder.TextName.setText(list.get(position).getName());
		mViewHolder.TextArm.setText(list.get(position).getArm());
		mViewHolder.TextText.setText(list.get(position).getText());
		return convertView;
	}

}
